#include base

(defun cas (loc old new)
  (atomic (let ((val (@ loc)))
	    (when (= old val)
		(@= loc new))
	    val)))
